<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" 
	import="java.util.List,com.telecom.cms.dao.*,com.telecom.cms.dto.*" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
<head>
	<title>集成取数结果展示</title>
	<LINK href="css/default.css" rel=stylesheet>
	<LINK href="css/button.css" rel=stylesheet>
	<LINK href="css/main.css" type=text/css rel=stylesheet>
	<script type="text/javascript" src="js/dtree.js"></script>
<script type="text/javascript">
	function opchange(o){
		document.idaTemplateForm.method.value=o;
		document.idaTemplateForm.submit();
	}
	
	function showHiddenDiv(id){
		if(id=="sqlarea"){
			document.getElementById("paramarea").style.display="none";
			document.getElementById("filtresultarea").style.display="none";
			document.getElementById("instancearea").style.display="none";
		}
		if(id=="paramarea"){
			document.getElementById("sqlarea").style.display="none";
			document.getElementById("filtresultarea").style.display="none";
			document.getElementById("instancearea").style.display="none";
		}
		if(id=="filtresultarea"){
			document.getElementById("sqlarea").style.display="none";
			document.getElementById("paramarea").style.display="none";
			document.getElementById("instancearea").style.display="none";
		}
		if(id=="instancearea"){
			document.getElementById("sqlarea").style.display="none";
			document.getElementById("paramarea").style.display="none";
			document.getElementById("filtresultarea").style.display="none";
		}
		var divstyle=document.getElementById(id).style.display;
		if(divstyle=="none")
			document.getElementById(id).style.display="";
		else
			document.getElementById(id).style.display="none";
	}
	
	function exportData(spanId,fileName){
		document.all.exportFileName.value = fileName+".xls";
	    exportExcel(document.getElementById(spanId).innerHTML,'export');
		document.all.exportFileName.value=fileName;
	}
	
	function exportExcel(s,URL){
	    var oldAction=document.forms[0].action; 
		document.forms[0].exportContent.value="<META content=text/html; charset=GBK http-equiv=Content-Type/>"+s;
		document.forms[0].action=URL;
		document.forms[0].submit();	
		document.forms[0].action = oldAction;
	}
</script>
</head>
<body>
<html:form action="/ida">
<table width="1000" cellspacing="0" cellpadding="0" border="0" align="center">
<tbody>
	<tr>
		<td width="3" height="31">
			<img height="31" src="./images/table_01.gif" width="3" />
		</td>
		<td background="./images/table_02.gif" height="31">
			<table cellspacing="0" cellpadding="0" width="170" align="left" border="0">
				<tbody>
					<tr>
						<td width="51" background="./images/title_1_bg.gif">
							<img height="31" src="./images/title_1.gif" width="51" />
						</td>
						<td width="150" background="./images/title_1_bg.gif">
							<span class="color_b_666">集成取数结果展示</span>
						</td>
					</tr>
				</tbody>
			</table>
		</td>
		<td width="3">
			<img height="31" src="./images/table_03.gif" width="3" />
		</td>
	</tr>
	<tr>
		<td background="images/table_04.gif">
			<img height="5" src="images/table_04.gif" width="3">
		</td>
		<td style="PADDING-TOP: 3px" valign="top">
		<logic:present name="errorInfo.emptyParamName" scope="request">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				对不起！ <bean:write name="errorInfo.emptyParamName" /> 域为必填项，请将信息填写完整后重新执行，谢谢！&nbsp;&nbsp;
				【<a href="#" onclick="javascript:history.back(0);">返回</a>】
		</logic:present>
		<logic:notPresent name="errorInfo.emptyParamName" scope="request">
			<div align="left" id="menu">
				<input class=btn_mouseout type="button"
					onmouseover="this.className=&#39;btn_mouseover&#39;"
					onmouseout="this.className=&#39;btn_mouseout&#39;"
					onmousedown="this.className=&#39;btn_mousedown&#39;"
					onmouseup="this.className=&#39;btn_mouseup&#39;" value="查看执行语句"
					onclick="showHiddenDiv('sqlarea')">
				<input class=btn_mouseout type="button"
					onmouseover="this.className=&#39;btn_mouseover&#39;"
					onmouseout="this.className=&#39;btn_mouseout&#39;"
					onmousedown="this.className=&#39;btn_mousedown&#39;"
					onmouseup="this.className=&#39;btn_mouseup&#39;" value="查看条件"
					onclick="showHiddenDiv('paramarea')">
				<input class=btn_mouseout type="button"
					onmouseover="this.className=&#39;btn_mouseover&#39;"
					onmouseout="this.className=&#39;btn_mouseout&#39;"
					onmousedown="this.className=&#39;btn_mousedown&#39;"
					onmouseup="this.className=&#39;btn_mouseup&#39;" value="在结果中筛选"
					onclick="showHiddenDiv('filtresultarea')">
				<input class=btn_mouseout type="button"
					onmouseover="this.className=&#39;btn_mouseover&#39;"
					onmouseout="this.className=&#39;btn_mouseout&#39;"
					onmousedown="this.className=&#39;btn_mousedown&#39;"
					onmouseup="this.className=&#39;btn_mouseup&#39;" value="实例化我的取数"
					onclick="showHiddenDiv('instancearea')">
				<logic:lessEqual name="pageCount" value="1">
					<input class=btn_mouseout type="button"
						onmouseover="this.className=&#39;btn_mouseover&#39;"
						onmouseout="this.className=&#39;btn_mouseout&#39;"
						onmousedown="this.className=&#39;btn_mousedown&#39;"
						onmouseup="this.className=&#39;btn_mouseup&#39;" value="导出结果文件"
						onclick="exportData('spanId1','<%= System.currentTimeMillis() %>');">
				</logic:lessEqual>
				<logic:greaterThan name="pageCount" value="1">
					<input class=btn_mouseout type="button"
						onmouseover="this.className=&#39;btn_mouseover&#39;"
						onmouseout="this.className=&#39;btn_mouseout&#39;"
						onmousedown="this.className=&#39;btn_mousedown&#39;"
						onmouseup="this.className=&#39;btn_mouseup&#39;" value="导出结果文件"
						onclick="javascript:window.open('ida/idaExport.jsp');">
				</logic:greaterThan>
			</div>
		<logic:present name="idaSql" scope="session">
			<table id="sqlarea" style="display: none" width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#D5D5D5" align="center">
				<tr align="center">
					<td>
						<textarea cols="121" rows="15" readonly="readonly">${idaSql}</textarea>
					</td>
				</tr>
			</table>
		</logic:present>
		<logic:present name="paramValues" scope="session">
			<table id="paramarea" style="display: none" width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#D5D5D5" align="center">
				<tr>
					<th align="center" width="15%">参数名称</th>
					<th align="center" width="85%">参数取值</th>
				</tr>
				<logic:iterate name="paramValues" id="p">
					<tr>
						<logic:iterate name="p" id="v">
							<td><bean:write name="v" /></td>
						</logic:iterate>
					</tr>
				</logic:iterate>
			</table>
		</logic:present>
		<logic:present name="filtResult" scope="session">
			<table id="filtresultarea" style="display: none" width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#D5D5D5" align="center">
				<tr>
					<th align="center" width="15%">筛选字段</th>
					<th align="center" width="85%">筛选值</th>
				</tr>
				${filtResult}
				<tr>
					<td align="left" colspan="2">&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="button" onclick="opchange('doQueryInResult')" value="在结果中查询">
					</td>
				</tr>
			</table>
		</logic:present>
		<logic:present name="instanceResultAtoms" scope="session">
			<table id="instancearea" style="display: none" width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#D5D5D5" align="center">
				<tr>
					<th align="center" width="15%">请输入取数实例的名称</th>
					<th align="left" width="85%">
						<input type="text" name="instanceName" value="" size="50">&nbsp;&nbsp;
						<input type="checkbox" name="rewriteInst" value="T" checked>覆盖同名实例&nbsp;&nbsp;
						<input type="checkbox" name="deleteInst" value="T">删除该模板的实例&nbsp;&nbsp;
						<input type="button" onclick="opchange('saveInstance')" value="确  定">
						<input type="hidden" name="templateId" value="${instanceTemplateId}" />
						<input type="hidden" name="fromResultPage" value="T" />
					</th>
				</tr>
			</table>
		</logic:present>
		<logic:notPresent name="instanceResultAtoms" scope="session">
			<table id="instancearea" style="display: none" width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#D5D5D5" align="center">
			</table>
		</logic:notPresent>
		</logic:notPresent>
		<br>
		<logic:present name="idaData" scope="request">
			<table width='100%' border='0' cellspacing='' cellpadding='2'>
				<tr>
					<td align="left" valign="bottom">
						<a href="ida.do?method=doPagingQuery&paging=first">首页</a>
						<a href="ida.do?method=doPagingQuery&paging=previous">上一页</a>
						<a href="ida.do?method=doPagingQuery&paging=next">下一页</a>
						<a href="ida.do?method=doPagingQuery&paging=last">末页</a>
						&nbsp;&nbsp;&nbsp;&nbsp;
						共<bean:write name="rowCount" />条记录，当前第<bean:write name="pageNo" />页，共<bean:write name="pageCount" />页
					</td>
					<td align="right" valign="bottom">&nbsp;</td>
				</tr>
				<tr>
					<td align="left" colspan="2">
						<span id="spanId1">
						<table width='100%' border='0' cellspacing='1' cellpadding='2'>
							<tr align="center" height="25">
								<logic:iterate name="resultAtoms" id="a">
									<td background="images/table_bg0.GIF"><bean:write name="a" property="BIZ_ATOM_NAME"/></td>
								</logic:iterate>
							</tr>
							<%
								List idaData = (List)request.getAttribute("idaData");
								for (int i = 0; i < idaData.size(); i++){
									out.println("<tr height='20'>");
									String[] row = (String[])idaData.get(i);
									for (int j = 0; j < row.length; j++)
										out.println("<td>" + row[j] + "</td>");
									out.println("</tr>");
								}
							%>
						</table>
						</span>
					</td>
				</tr>
			</table>
		</logic:present>
		</td>
		<td background="images/table_05.gif">
			<img height="5" src="images/table_05.gif" width="3">
		</td>
	</tr>
	<tr height="3">
		<td height="3">
			<img height="12" src="images/table_06.gif" width="3">
		</td>
		<td height="3">
			<img height="3" src="images/table_07.gif" width="994">
		</td>
		<td height="3">
			<img height="12" src="images/table_08.gif" width="3">
		</td>
	</tr>
</tbody>
</table>
<br />
<html:hidden property="method" value="doPagingQuery" />
<input type="hidden" name="exportFileName" value="" />
<input type="hidden" name="exportContent"  value="" />
</html:form>
</body>
</html>